package Jordan;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;

import javax.swing.BorderFactory;
import javax.swing.DefaultListModel;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;
import javax.swing.border.BevelBorder;



/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class ROLgui extends javax.swing.JFrame {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1647544652413230327L;
	private JTabbedPane Tabs;
	private JComponent pPJs,pNPJs,pMap,pMaster;
	private JLabel Imagen;
	private JLabel PjsActuales;
	private JLabel PJsDisponibles;
	private JButton cargarDir;
	private JButton moveIzq;
	private JList PjsDisponibles;
	private JButton moveDer;
	private JList PjsenPartida;
	private JPanel pjsgrilla;
	private JButton plus;
	private JButton minus;
	private JLabel HP;
	private JLabel Nombre;
	private JPanel PJs;
	private JTextField ConsolaSuccesos;

	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				ROLgui inst = new ROLgui();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public ROLgui() {
		super("RoleMasterManager");
		pPJs=new JPanel();
		AnchorLayout pPJsLayout = new AnchorLayout();
		pPJs.setLayout(pPJsLayout);
		{
			ConsolaSuccesos = new JTextField();
			pPJs.add(ConsolaSuccesos, new AnchorConstraint(23, 985, 465, 293, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
			ConsolaSuccesos.setText("jTextField1");
			ConsolaSuccesos.setBackground(new java.awt.Color(0,0,0));
			ConsolaSuccesos.setForeground(new java.awt.Color(255,255,255));
			ConsolaSuccesos.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
			ConsolaSuccesos.setEditable(false);
			ConsolaSuccesos.setPreferredSize(new java.awt.Dimension(539, 236));
		}
		{
			PJs = new JPanel();
			AnchorLayout PJsLayout = new AnchorLayout();
			PJs.setLayout(PJsLayout);
			pPJs.add(PJs, new AnchorConstraint(487, 985, 978, 16, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
			PJs.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0,0,0)));
			PJs.setBackground(new java.awt.Color(192,192,192));
			PJs.setPreferredSize(new java.awt.Dimension(755, 262));
			{
				pjsgrilla = new JPanel();
				BorderLayout pjsgrillaLayout = new BorderLayout();
				pjsgrilla.setLayout(pjsgrillaLayout);
				PJs.add(pjsgrilla, new AnchorConstraint(143, 987, 967, 13, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
				pjsgrilla.setPreferredSize(new java.awt.Dimension(735, 216));
			}
			{
				plus = new JButton();
				PJs.add(plus, new AnchorConstraint(40, 405, 127, 370, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
				plus.setText("+");
				plus.setPreferredSize(new java.awt.Dimension(27, 23));
			}
			{
				minus = new JButton();
				PJs.add(minus, new AnchorConstraint(40, 371, 127, 331, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
				minus.setText("-");
				minus.setPreferredSize(new java.awt.Dimension(30, 23));
			}
			{
				Nombre = new JLabel();
				PJs.add(Nombre, new AnchorConstraint(5, 151, 158, 15, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
				Nombre.setText("Nombre");
				Nombre.setPreferredSize(new java.awt.Dimension(103, 40));
			}
			{
				HP = new JLabel();
				PJs.add(HP, new AnchorConstraint(5, 330, 158, 257, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
				HP.setText("HP");
				HP.setPreferredSize(new java.awt.Dimension(55, 40));
			}
		}
		{
			ImageIcon img=new ImageIcon("w40k.jpg");
			Imagen = new JLabel(img);
			pPJs.add(Imagen, new AnchorConstraint(23, 277, 465, 16, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
//			Imagen.setText("imgActual");
			Imagen.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0,0,0)));
			Imagen.setPreferredSize(new java.awt.Dimension(204, 236));
		}
		pMap=new JPanel();
		pNPJs=new JPanel();
		pMaster=new JPanel();
		AnchorLayout pMasterLayout = new AnchorLayout();
		pMaster.setLayout(pMasterLayout);
		{
			PjsActuales = new JLabel();
			pMaster.add(PjsActuales, new AnchorConstraint(30, 371, 94, 257, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
			PjsActuales.setText("PJs Actuales");
			PjsActuales.setPreferredSize(new java.awt.Dimension(89, 34));
		}
		{
			PJsDisponibles = new JLabel();
			pMaster.add(PJsDisponibles, new AnchorConstraint(23, 153, 103, 45, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
			PJsDisponibles.setText("PJs Disponibles para cesion");
			PJsDisponibles.setPreferredSize(new java.awt.Dimension(84, 43));
		}
		{
			
			cargarDir = new JButton();
			pMaster.add(cargarDir, new AnchorConstraint(126, 643, 169, 411, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
			cargarDir.setText("cargar directorio de pjs");
			cargarDir.setPreferredSize(new java.awt.Dimension(181, 23));
			cargarDir.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent evt) {
					System.out.println("cargarDir.actionPerformed, event="+evt);
					//TODO add your code for cargarDir.actionPerformed
					JFileChooser fc=new JFileChooser();
					fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
					int seleccion = fc.showOpenDialog(pMaster);
					if (seleccion == fc.APPROVE_OPTION)
					{
						try{
							File fichero = fc.getSelectedFile();
							File[] pjsdisp=fichero.listFiles();
							String[] pjsdispnames=fichero.list();
							PjsDisponibles.setListData(pjsdispnames);
						}
						catch(Exception e){
							e.printStackTrace();
						}
					}
				}
			});
		}
		{
			moveIzq = new JButton();
			pMaster.add(moveIzq, new AnchorConstraint(261, 234, 304, 176, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
			moveIzq.setText("<");
			moveIzq.setPreferredSize(new java.awt.Dimension(45, 23));
		}
		{
			final DefaultListModel PjsenPartidaModel = new DefaultListModel();
			PjsenPartida = new JList(PjsenPartidaModel);
			pMaster.add(PjsenPartida, new AnchorConstraint(126, 372, 427, 258, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
			PjsenPartida.setModel(PjsenPartidaModel);
			PjsenPartida.setPreferredSize(new java.awt.Dimension(89, 161));
			PjsenPartida.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
			PjsenPartida.setBackground(new java.awt.Color(238,238,238));
//		}
//		{
			final DefaultListModel PjsDisponiblesModel = new DefaultListModel();
			PjsDisponibles = new JList(PjsDisponiblesModel);
			pMaster.add(PjsDisponibles, new AnchorConstraint(126, 153, 427, 46, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
			PjsDisponibles.setModel(PjsDisponiblesModel);
			PjsDisponibles.setPreferredSize(new java.awt.Dimension(83, 161));
			PjsDisponibles.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
			PjsDisponibles.setBackground(new java.awt.Color(238,238,238));
//		}
//		{
			moveDer = new JButton();
			pMaster.add(moveDer, new AnchorConstraint(324, 234, 366, 176, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
			moveDer.setText(">");
			moveDer.setPreferredSize(new java.awt.Dimension(45, 22));
			moveDer.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent evt) {
					System.out.println("moveDer.actionPerformed, event="+evt);
					//TODO add your code for moveDer.actionPerformed
					if(!PjsenPartidaModel.contains(PjsDisponibles.getSelectedValue())){
						PjsenPartidaModel.addElement(PjsDisponibles.getSelectedValue());
						pjsgrilla.add(new JLabel(PjsDisponibles.getSelectedValue().toString()));
					}
				}
			});
		}

		initGUI();
	}
	
	private void initGUI() {
		try {
			AnchorLayout thisLayout = new AnchorLayout();
			getContentPane().setLayout(thisLayout);
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			{
				Tabs = new JTabbedPane();
				Tabs.addTab("PJs", pPJs);
				Tabs.addTab("NPJs", pNPJs);
				Tabs.addTab("Master", pMaster);
				Tabs.addTab("Map",pMap);
				getContentPane().add(Tabs, new AnchorConstraint(0, 1000, 1000, 0, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
				Tabs.setPreferredSize(new java.awt.Dimension(784, 562));
			}
			pack();
			this.setSize(800, 600);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}

}
